package handler

import (
	"team-mate/moder"

	"github.com/gin-gonic/gin"
)

func DepotAdd(c *gin.Context) {
	DepotName := c.PostForm("DepotName")
	Depots := c.PostForm("Depots")
	if DepotName == "" || Depots == "" {
		c.JSON(200, gin.H{
			"mas":  "不能为空",
			"code": 500,
		})
		return
	}
	depot := moder.Depot{
		DepotName: DepotName,
		Depots:    Depots,
	}
	err := moder.DB.Create(&depot).Error
	if err != nil {
		c.JSON(200, gin.H{
			"mas":  "添加失败",
			"code": 500,
		})
		return
	}

	c.JSON(200, gin.H{
		"mas":  "成功",
		"code": 200,
	})
	return

}
